﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GuidanceExplorer.Model;
using GuidanceExplorerAddIn.Controls;

namespace GuidanceExplorerAddIn.Views
{
    public partial class ChecklistItemView : GuidanceItemView
    {
        public Checklist ParentChecklist { private get; set; }

        public GEGridView ParentGrid { private get; set; }

        public ChecklistItemView()
        {
            InitializeComponent();
        }


        /// <summary>
        /// Show the details of the item in the details pane.
        /// </summary>
        public void ShowDetails(GuidanceItemFileReference guidanceItem, Checklist parentChecklist)
        {
            ParentChecklist = parentChecklist;
            _guidanceItem = guidanceItem;
            detailView.ShowDetails(guidanceItem);
           // txtNotes.Select(0, 0);
            txtNotes.Text = parentChecklist.GetItemNotes(guidanceItem.Id);
        }

        /// <summary>
        /// Ocurs when the content of the notes text box is modified
        /// </summary>
        private void txtNotes_TextChanged(object sender, EventArgs e)
        {
            // Save the new item notes
            ParentChecklist.SetItemNotes(_guidanceItem.Id, txtNotes.Text);

            //If comes from a grid
            if (ParentGrid != null)
                ParentGrid.RefreshCheckList();

        }
    }
}
